﻿@model List<CanDichVu.Db.ChuyenMuc>


<script type="text/javascript">
    $(document).ready(function () {

        makeEventDialog("a.update_cate_ad");

        $("a.detele").click(function () {
            var $this = $(this);
            var CateName = $this.closest('tr').find('.spanNameCate').html();
            if (confirm("Bạn muốn xóa đơn hàng : " + CateName + "")) {
                var Cateid = $this.closest('tr').find('.Cate-id').html();
                $.get("/Admin/Ad_Cate/Delete?id=" + Cateid, function (data) {
                    makeRequest(data);
                });
            }
        });

    });

    function makeRequest(obj) {

        if (obj.Status == "success") {
            if (obj.Message != null) {
                alert(obj.Message);
            }
            else if (obj.RedirectUrl != null) {
                window.location.href = obj.RedirectUrl;
            }
        } else {
            alert(obj.Message);
        }

        return false;
    }



</script>

<form action="/Admin/Ad_Cate/UpdateMuitl" method="POST" style="position: relative; padding-top: 5px">
    <table class="table_admin">
        <thead>
            <tr>
                <th></th>
                <th scope="col" class="rounded">Tên chuyên mục
                </th>
                <th scope="col" class="rounded">Thứ Tự
                </th>
                <th scope="col" class="rounded">Chuyên mục hot
                </th>
                <th scope="col" class="rounded">Edit
                </th>
                <th scope="col" class="rounded">Delete
                </th>
                <th></th>
            </tr>
        </thead>
        <tfoot>
            <tr>
                <td colspan="8" class="rounded-foot-left">
                    <em>Danh sách chuyên mục rao vặt</em>
                </td>
            </tr>
        </tfoot>
        <tbody>
            @if (Model.Count() > 0)
            {
                for (int i = 0; i < Model.Count; i++)
                {
            
                <tr>
                    <td>
                        @Html.HiddenFor(it => Model[i].Id)
                        <span class="Cate-id" style="display: none;">@Model[i].Id</span>
                    </td>
                    <td>
                        <span class="spanNameCate">@Model[i].TenChuyenMuc</span>
                    </td>
                     <td>
                         @Html.TextBoxFor(model => Model[i].stt, new { @class = "txt_inp" })
                    </td>
                    <td>
                         @Html.EditorFor(x => Model[i].Hot)
                     </td>
                    <td>
                        <a class="update_cate_ad" data-dialog-title="Cập nhật chuyên mục @Model[i].TenChuyenMuc" data-dialog-id="Update_cate_ad_id"  href="/Admin/Ad_Cate/Update?id=@Model[i].Id">
                            <input type="image" src="/Content/AdminThemes/images/icn_edit.png" title="Edit">
                        </a>
                    </td>
                    <td>
                        <a href="javascript:void(0)" class="detele">
                            <input type="image" src="/Content/AdminThemes/images/icn_trash.png" title="detele">
                    </td>
                </tr>
                }
            }
            else
            {
                <tr>
                    <td colspa="3">

                        Không có chuyên mục nào

                    </td>

                </tr>
            }
        </tbody>
    </table>
    <footer>
        <div class="submit_link">
            <input type="submit" value="Cập nhật chuyên mục" class="alt_btn button_ad">
            <input type="button" value="Thêm mới chuyên mục" class="add_new_cate button_ad" data-dialog-href="/Admin/Ad_Cate/Add" data-dialog-title="Thêm mới chuyên mục" data-dialog-id="add_new_cate_id">
        </div>
    </footer>
</form>
